home *** CD-ROM | disk | FTP | other *** search
/ Die Speccy' 97 / Die Speccy' 97.iso / amiga_system / the_aminet / util / boot / snap_v2_0.lha / Snap / SnapAsm.s < prev    next >
Text File  |  1995-09-04  |  9KB  |  240 lines

  1.         XDEF    _interpret       ; Bitmap-to-Ascii function
  2.         XDEF    _CopyFont        ; Copies a font and aligns it to 16 bit.
  3.         XREF    _CharData        ; Font data
  4.         XREF    _SrcData
  5.         XREF    _CharLoc
  6.         XREF    _CharKern
  7.         XREF    _Modulo
  8.         XREF    _FontWidth
  9.         XREF    _FontHeight
  10.         XREF    _Underscore
  11.         XREF    _TrueUnderscore
  12.         XREF    _LoChar
  13.         XREF    _HiChar
  14.         XREF    _IFlags
  15.  
  16.         XDEF   _myActivateWindow
  17.  
  18.         SECTION CODE
  19.  
  20. USC     equ 1                   ; Interpreted char was underscored
  21. PUSC    equ 2                   ; Prevoius char was underscored
  22. PUS     equ 4                   ; Pending underscored space
  23. CHEIGHT equ 24                  ; Max height of unpacked character
  24.  
  25. _interpret:
  26.         link    a5,#0
  27.         movem.l d1-d6/a1,-(sp)   ; Free a couple of registers
  28.         move.l  8(a5),a1         ; Bitmap
  29.         move.w  (a1),d2          ; First row
  30.         moveq   #0,d4            ; Code
  31.         move.b  _LoChar,d4       ; First char
  32.         move.w  _FontWidth,d0
  33.         asl.w   #1,d0            ; Times two for words
  34.         lea     MaskTable,a0
  35.         move.w  0(a0,d0.w),d3    ; d3 := mask
  36.         move.l  _CharData,a0     ; Char image data
  37.         bclr.b  #PUS,_IFlags     ; No pending-underscored-space
  38. .lp1
  39.         cmpi.b  #31,d4           ; Into printable characters yet?
  40.         bhi     .Search          ; If yes, go and start searching
  41.         addq    #1,d4            ; Move to next char
  42.         adda.l  #CHEIGHT*2,a0    ; Increment bitmap ptr also
  43.         bra     .lp1             ; Back to check again
  44. .Search
  45.         cmp.w   (a0),d2          ; Compare first word
  46.         bne     .tryinverted     ; Not this one
  47.         bclr.b  #USC,_IFlags     ; Assume not underscored
  48.         moveq   #1,d5            ; current word
  49.         moveq   #0,d6            ; Modulo
  50. .morerows
  51.         addq    #2,d6            ; Add modulo - next bit row in image data
  52.         move.w  0(a0,d6.w),d1    ; Character row
  53.         cmp.w   0(a1,d6.w),d1
  54.         beq     .stdmatch        ; Rows matched
  55.         cmp.w   _Underscore,d5   ; Could it be the underscore line?
  56.         bne     .tryinverted     ; Nope
  57.         tst.b   _TrueUnderscore  ; Use true underscore?
  58.         beq     .uscmatch        ; No. Let's hope it's okay
  59.         moveq   #0,d1            ;   00000000
  60.         move.w  0(a0,d6.w),d0    ;   00110000
  61.         or.w    d0,d1            ;   00110000
  62.         rol.l   #2,d1            ; 0011000000
  63.         or.w    d0,d1            ; 0011110000
  64.         ror.l   #1,d1            ;  X01111000
  65.         eor.w   d3,d1            ;   10000111
  66.         or.w    d0,d1            ;   10110111
  67.         move.w  0(a1,d6.w),d0
  68.         eor.w   d0,d1            ;   Zero if equal
  69.                                  ; But, let's skip the last bit since it
  70.                                  ; may be affected by the next character
  71.         lsr.w   #1,d1            ; Shift one step right
  72.         and.w   d3,d1            ; Mask out last bit
  73.         bne     .tryinverted
  74. .uscmatch
  75.         bset.b  #USC,_IFlags     ; Set underscored flag
  76. .stdmatch
  77.         addq    #1,d5            ; Next row in bitmap
  78.         cmp.w   _FontHeight,d5   ; Are we done?
  79.         bne     .morerows        ; Not yet
  80.         cmp.b   #' ',d4           ; Space
  81.         bne     .notuspace
  82.         ; Space. Check for underscore
  83.         btst.b  #USC,_IFlags     ; Underscored char?
  84.         beq     .notuspace       ; Nope, everything ok
  85.         ; Underscored space. Check if previous char was underscored
  86.         btst.b  #PUSC,_IFlags    ; Previous char underscored?
  87.         bne     .okuspace        ; Yep, ok underscored space
  88.         ; Previous char not underscored. Set pending-underscored-space flag
  89.         ; and go on to check if the normal underscore char matches
  90.         bset.b  #PUS,_IFlags
  91.         bra     .tryinverted
  92.  
  93. .notuspace
  94. .okuspace
  95.         bclr.b  #PUSC,_IFlags    ; Clear previous-underscored
  96.         btst.b  #USC,_IFlags     ; Underscored char?
  97.         beq     .interpreted     ; Nope
  98.         bset.b  #PUSC,_IFlags    ; Set previous-underscored
  99.         bra     .interpreted     ; Got it
  100.  
  101. .tryinverted
  102.         move.w  (a0),d1          ; Copy first row
  103.         eor.w   d3,d1            ; and invert the bits
  104.         cmp.w   d2,d1            ; Compare inverted rows
  105.         bne     .trybold         ; No match
  106.         moveq   #1,d5            ; current row
  107.         moveq   #0,d6            ; Modulo
  108. .moreinverted
  109.         addq    #2,d6
  110.         move.w  0(a0,d6.w),d1    ; Character row
  111.         eor.w   d3,d1            ; and invert the bits
  112.         cmp.w   0(a1,d6.w),d1
  113.         bne     .trybold         ; Rows didn't match
  114.         addq    #1,d5            ; Next row in bitmap
  115.         cmp.w   _FontHeight,d5   ; Are we done?
  116.         bne     .moreinverted    ; Not yet
  117.         bra     .interpreted     ; Got it
  118.  
  119. .trybold
  120.         move.w  (a0),d1          ; Copy first row
  121.         lsr.w   #1,d1            ; Shift one step left
  122.         or.w    (a0),d1          ; Make bold
  123.         and.w   d3,d1            ; and mask out unwanted bits
  124.         cmp.w   d2,d1            ; Compare bold rows
  125.         bne     .trynext         ; No match
  126.         moveq   #1,d5            ; current row
  127.         moveq   #0,d6            ; Modulo
  128. .morebold
  129.         addq    #2,d6
  130.         move.w  0(a0,d6.w),d1    ; Character row
  131.         lsr.w   #1,d1            ; Shift one step left
  132.         or.w    0(a0,d6.w),d1    ; Make bold
  133.         and.w   d3,d1            ; and mask out unwanted bits
  134.         cmp.w   0(a1,d6.w),d1
  135.         bne     .trynext         ; Rows didn't match
  136.         addq    #1,d5            ; Next row in bitmap
  137.         cmp.w   _FontHeight,d5   ; Are we done?
  138.         bne     .morebold        ; Not yet
  139.         bra     .interpreted     ; Got it
  140.  
  141. .trynext
  142.         adda.l  #CHEIGHT*2,a0    ; Try next character, 32 bytes/char
  143.         cmp.b   _HiChar,d4       ; Tried all chars?
  144.         beq     .nomore          ; No more to try
  145.         addq    #1,d4            ; Next char
  146.         bra     .Search
  147.  
  148. .nomore
  149.         move.l  #0,d4            ; Not found
  150.         btst.b  #PUS,_IFlags     ; Hey, perhaps it was an underscored space?
  151.         beq     .interpreted     ; Nope, return not-found
  152.         move.l  #' ',d4
  153.  
  154. .interpreted
  155.         move.l  d4,d0
  156.         movem.l (sp)+,d1-d6/a1
  157.         unlk    a5
  158.         rts
  159.  
  160.  
  161. _CopyFont:
  162.         movem.l d2-d6/a2/a3/a5,-(sp)   ; Free a couple of registers
  163.         moveq   #0,d0
  164.         moveq   #0,d6               ; Don't shift if no kerning data
  165.         move.l  _CharData,a2        ; a2 := Destination area
  166.         move.l  _CharLoc,a3
  167.         move.l  _CharKern,a5
  168.         move.b  _LoChar,d5
  169.         move.w  _Modulo,d3
  170.  
  171. .NextChar
  172.         move.w  (a3)+,d0            ; Get char location
  173.         move.w  d0,d1
  174.         and.w   #15,d1              ; Shift amount
  175.         eori.b  #15,d1              ; Negate shift value
  176.         addq.b  #1,d1               ; d1 := Shift Amount
  177.         cmpa.l  #0,a5               ; Check for kerning data
  178.         beq     .nokern             ; No kerning to adjust for
  179.         move.w  (a5)+,d6            ; Kerning
  180.  
  181. .nokern
  182.         move.l  _SrcData,a0
  183.         lsr.w   #3,d0               ; Byte offset
  184.         bclr    #0,d0               ; But we deal in words
  185.         adda.w  d0,a0               ; a0 := chardata
  186.  
  187.         move.w  (a3)+,d0            ; Get char width
  188.         asl.w   #1,d0               ; Times two for words
  189.         lea     MaskTable,a1
  190.         move.w  0(a1,d0.w),d2       ; d2 := mask
  191.  
  192.         moveq   #0,d4
  193.         move.w  _FontHeight,d4
  194.         move.l  a2,a1               ; a1 := Destination area
  195.         adda.w  #CHEIGHT*2,a2       ; a2 to next dest area
  196.         bra     .loop
  197. .copyrow
  198.         move.l  (a0),d0             ; Get character row
  199.         adda.w  d3,a0               ; Add modulo -- To next row
  200.         lsr.l   d1,d0               ; Shift data to bit 0 alignment
  201.         and.w   d2,d0               ; Mask out unwanted bits
  202.         lsr.w   d6,d0               ; Shift according to kerning
  203.         move.w  d0,(a1)+            ; Save row
  204. .loop
  205.         dbra    d4,.copyrow         ; Do all rows
  206.  
  207.         cmp.b   _HiChar,d5          ; Finished?
  208.         beq     .copydone           ; Yes
  209.         addq    #1,d5               ; Next char
  210.         bra     .NextChar           ; Nope -- do next.
  211.  
  212. .copydone
  213.         movem.l (sp)+,d2-d6/a2/a3/a5
  214.         rts
  215.  
  216. MaskTable
  217.         dc.w    $0000
  218.         dc.w    $8000
  219.         dc.w    $c000
  220.         dc.w    $e000
  221.         dc.w    $f000
  222.         dc.w    $f800
  223.         dc.w    $fc00
  224.         dc.w    $fe00
  225.         dc.w    $ff00
  226.         dc.w    $ff80
  227.         dc.w    $ffc0
  228.         dc.w    $ffe0
  229.         dc.w    $fff0
  230.         dc.w    $fff8
  231.         dc.w    $fffc
  232.         dc.w    $fffe
  233.         dc.w    $ffff
  234.  
  235.  
  236. _myActivateWindow:
  237.         rts
  238.  
  239.         END
  240.